#!/bin/bash
script_folder="/home/aqdms/CARBLog/sys_resources/scripts"
temp_file="/home/aqdms/CARBLog/sys_resources/scripts/temp_file"
inst_name="$1"

header="Driver,CL Date,CONC,QTOT, WS, WD, ROOM, RH, Delta, AT "
header="$header, External Reset, Telemetry Fault, Maintenance, Internal CPU, Power Fail, Reference Membrane, Nozzle Stuck"
header="$header, Flow Error, Pressure Drop Excessive, Deviant Membrane Density, Count Error, Tape Break, BAM Date "

echo $header > $temp_file
#cat $script_folder/$2 | grep "$inst_name=" | sed 's/:::'$inst_name'=/,/g' | sed 's/::/,/g' |  sed 's/ QTOT[0-9]=/,/g' >> $temp_file
cat $script_folder/$2 | grep -v "CONFIG" | sed 's/:::'$inst_name'=/,/g' | sed 's/::/,/g' |  sed 's/ QTOT[0-9]=/,/g' >> $temp_file
rm $script_folder/$2
mv "$temp_file" "$script_folder/$2"

exit

